package com.zzxy.springmvc2.controller;

import com.zzxy.springmvc2.po.Student;
import com.zzxy.springmvc2.po.StudentExt;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import sun.security.util.Password;

@Controller
@RequestMapping("/stu")
public class StudentController {
    @RequestMapping("/register")
    private String register() {
        return "/user/register";
    }

    @RequestMapping("insert")
    public Student insert(@RequestBody Student student){
        student.setPassword(student.getPassword()+":qwe");
        student.setUsername(student.getUsername()+":asd");
        //sservice > dao> MyBatis
        return student;
    }

    @RequestMapping("/addStu")
    public String addStu(String username, String Password){
        System.out.println(username);
        System.out.println(Password);
        //service > dao > insert into student...
        return "/user/userlist";
    }

    @RequestMapping("/addStu1")
    public String addStu(Student student){
        System.out.println(student);
        //service > dao > insert into student...
        return "/user/userlist";
    }

    @RequestMapping("/addStu2")
    public String addStu(StudentExt ext){
        System.out.println(ext);
//        for (Student student : ext.getStudentList()) {
//            System.out.println(student);
//        }

        //service > dao > insert into student...
        return "/user/userlist";
    }

    @RequestMapping("test")
    public String test() {
        return "forward:/register.do";
    }

    @RequestMapping("test1")
    public String test1() {
        return "redirect:/register.do";
    }
}
